<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class IndexController extends Controller
{

    public function index()
    {
        return '前台主页，暂无内容';
    }

    public function make()
    {
        return view('home.index.make');
    }

    public function uploadFile(Request $request)
    {
        $file = $request->file('shipin');
        $size = $file->getSize(); // 获取文件大小
        if($size > 1024*1024*200){
            return "文件不能大于200M";
        }

        $filename = $file->getClientOriginalName(); // 获取文件原始名称
        $file->move(public_path("/uploads"),$filename);

        //$path = "D:/wu/hailong/laravel_layui/public/uploads/";
        $path = "/www/wwwroot/convert.morelikely.cn/public/uploads/";
        $dir = $path.$filename;

        $gif_name = time().".gif";
        $dir2 = $path.$gif_name;

        $str = "/usr/local/ffmpeg/bin/ffmpeg -y -i ".$dir." -r 10 -s 216x384 ".$dir2;

        $data = exec($str);

//        foreach ($output as $line) {
//            echo $line . "\n";
//        }
        echo '<img src="/uploads/'.$gif_name.'" alt="">';

//        $path = exec('echo $PATH');
//        echo $path;

    }

}
